package com.xinlianshiye.im.bean

import java.util.*
import javax.persistence.*

/**
 * 用户账号表
 */
@Entity
@Table(name = "im_user")
class User : Domain() {
    @Column(name = "username", columnDefinition = "varchar(255) comment '用户昵称'")
    var username: String? = null

    @Column(name = "sign", columnDefinition = "varchar(255) comment '用户个性签名'")
    var sign: String? = null

    @Column(name = "status", columnDefinition = "tinyint(4) comment '用户在线状态'")
    var onlineState: OnlineStateEnum? = null

    @Column(name = "avatar", columnDefinition = "varchar(255) comment '用户头像'")
    var avatar: String? = null

    @Column(name = "logintime", columnDefinition = "datetime comment '用户登录时间/退出时间'")
    var loginTime: Date? = null

    @Column(name = "statusexist", columnDefinition = "varchar(255) comment '账户状态'")
    @Enumerated
    var accountStatus: AccountStatusEnum? = null

    @ManyToOne
    @JoinColumn(nullable = false, columnDefinition = "int(11) comment 'IM应用主键'", foreignKey = ForeignKey(name = "none"))
    var app: App? = null

    /**
     * 账户状态
     */
    enum class AccountStatusEnum {
        /**
         * 删除
         */
        Deleted,

        /**
         * 停用
         */
        Stop,

        /**
         * 正常
         */
        Normal
    }

    /**
     * 用户在线状态
     */
    enum class OnlineStateEnum {
        /**
         * 在线
         */
        ONLINE,

        /**
         * 离线
         */
        OFFLINE
    }
}